//
//  HYUser.m
//  HaiYue
//
//  Created by skyline on 2018/1/22.
//  Copyright © 2018年 skyline. All rights reserved.
//

#import "HYSettingManager.h"
NSString * const MESSAGE_PUSH = @"MESSAGE_PUSH"; //消息推送设置
NSString * const AUTO_INSTALL = @"AUTO_INSTALL"; //自动安装设置
NSString * const AUTO_DELETE = @"AUTO_DELETE";   //自动删除设置

@implementation HYSettingManager
static  HYSettingManager *_settingManager;
static dispatch_once_t onceToken;
+ (instancetype)manager
{
    if (!_settingManager)
    {
        dispatch_once(&onceToken, ^{
            _settingManager = [[HYSettingManager alloc] init];
        });
    }
    return _settingManager;
}

+ (void)initSetting{
    _settingManager = [HYSettingManager manager];
    _settingManager.messageOn = [[CCSave valueFromKey:MESSAGE_PUSH] isEqualToString:@"NO"]?NO:YES;
    _settingManager.installOn = [[CCSave valueFromKey:AUTO_INSTALL] isEqualToString:@"NO"]?NO:YES;
    _settingManager.deleteOn = [[CCSave valueFromKey:AUTO_DELETE] isEqualToString:@"NO"]?NO:YES;
}

- (void)setMessageOn:(BOOL)messageOn
{
    if (_messageOn != messageOn)
    {
        _messageOn = messageOn;
        NSString * string = (_messageOn)?@"YES":@"NO";
        [CCSave value:string forKey:MESSAGE_PUSH];
    }
}

- (void)setInstallOn:(BOOL)installOn
{
    if (_installOn != installOn)
    {
        _installOn = installOn;
        NSString * string = (_installOn)?@"YES":@"NO";
        [CCSave value:string forKey:AUTO_INSTALL];
    }
}
- (void)setDeleteOn:(BOOL)deleteOn
{
    if (_deleteOn != deleteOn)
    {
        _deleteOn = deleteOn;
        NSString * string = (_deleteOn)?@"YES":@"NO";
        [CCSave value:string forKey:AUTO_DELETE];
    }
}
@end
